home *** CD-ROM | disk | FTP | other *** search
- /*
- * illustrate the use of memory and string routines
- *
- * If _ABI_SOURCE is defined, redefine all the changed routines
- */
-
- #ifdef _ABI_SOURCE
- #include <string.h>
- #define ANSI_STRING
- #else
- #include <strings.h>
- #endif
- #ifdef _ABI_SOURCE
- #include <memory.h>
- #endif
- #include <stdio.h>
-
- #ifdef ANSI_STRING
-
- #ifndef index
- #define index(s, c) strchr((s), (c))
- #endif
- #ifndef rindex
- #define rindex(s, c) strrchr((s), (c))
- #endif
-
- #ifndef bcmp
- #define bcmp(s1, s2, n) memcmp ((s1), (s2), (n))
- #endif
- #ifndef bzero
- #define bzero(s, n) memset ((s), 0, (n))
- #endif
- #ifndef bcopy
- #define bcopy(s, d, n) memcpy ((d), (s), (n))
- #endif
-
- #else /* Not ANSI_STRING. */
-
- extern int bcmp ();
- extern void bzero ();
- extern void bcopy ();
-
- #endif /* ANSI_STRING. */
- #undef ANSI_STRING
-
-
- #define BUFFER 256
- char *string = "this is a test";
- char buf[BUFFER];
-
- main ()
- {
- int rv;
- char *cp;
-
- bzero (buf, BUFFER);
- bcopy (string, buf, strlen(string));
- rv = bcmp (string, buf, strlen(string));
- if ( rv == 0 )
- printf ("Copied strings match\n");
- cp = index (buf, 'a');
- if (cp != NULL)
- printf ("Found character in string\n");
-
- }
-